/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Rectangle;

/**
 *
 * @author hjess
 */

public abstract class Entity {

private int x;
private int y;
private int speedX;
private int speedY;
private int health;

private boolean isAlive;

private Rectangle bound; 

private int size;
private int hitpoint;
private Image img;

    public Entity(int x, int y, int dx, int dy, int size, int hitpoint, int speed, Image img) {
        this.x = x;
        this.y = y;
        this.speedX = dx;
        this.speedY = dy;
        this.size = size;
        this.hitpoint = hitpoint;
        this.img = img;
        this.health = 100;
        this.isAlive = true;
    }
        public int getHealth() {
        return health;
    }

    public void setHealth(int health) {
        this.health = health;
    }


    public Image getImg() {
        return img;
    }

    public int getX() {
        return x;
    }
    public int getCenterX() {
        return x+(size/2);
    }


    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public int getSpeedX() {
        return speedX;
    }

    public void setSpeedX(int speedX) {
        this.speedX = speedX;
    }

    public int getSpeedY() {
        return speedY;
    }

    public void setSpeedY(int speedY) {
        this.speedY = speedY;
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public int getHitpoint() {
        return hitpoint;
    }

    public void setHitpoint(int hitpoint) {
        this.hitpoint = hitpoint;
    }

    public Rectangle getBound() {
        return new Rectangle(x, y, x+size, y+size);
    }

public abstract void move();

/* Tjekker om de 2 firkanter overlapper hinanden */
public boolean collideWith(Entity e) { 
        boolean isHit = false;
        if (e.getBound().intersects(bound)) {
            isHit = true;
        }
        return isHit;
    }

    public void playerHit(int p) {
        health -= p;
        if (health <= 0) {
            isAlive = false;
        }
    }

    public boolean isIsAlive() {
        return isAlive;
    }

    public void setIsAlive(boolean isAlive) {
        this.isAlive = isAlive;
    }
 
}


